<template>
  <el-menu
      class="el-menu-vertical-demo"
      active-text-color="#ffd04b"
      :collapse="isCollapse"
  >
    <div class="kc-icon">
      <img src="../assets/kc.jpg">
      <span>IT课程管理系统</span>
    </div>
    <el-sub-menu index="1">
      <template #title>
        <el-icon><Document /></el-icon>
        <span>课程管理</span>
      </template>
        <el-menu-item index="1-1" @click="courseHandle('front')">前端课程</el-menu-item>
        <el-menu-item index="1-2" @click="courseHandle('back')">后端课程</el-menu-item>
        <el-menu-item index="1-3" @click="courseHandle('all')">全栈课程</el-menu-item>
    </el-sub-menu>

    <el-sub-menu index="2">
      <template #title>
        <el-icon><Setting /></el-icon>
        <span>用户管理</span>
      </template>
      <el-menu-item index="2-1">用户信息</el-menu-item>
      <el-menu-item index="2-2">item two</el-menu-item>
    </el-sub-menu>
  </el-menu>
</template>

<script setup>
import {defineProps} from 'vue';
import emitter from "../utils/eventBus";

const {isCollapse} =defineProps(['isCollapse'])

/**
 * 点击类目触发课程列表重新获取
 */
const courseHandle=(type)=>{
  emitter.emit('course', type)
  console.log('点击类目触发课程列表重新获取');
}
</script>

<style scoped>
.kc-icon {
  display: flex;
  align-items: center;
  font-weight: 600;
  height: 60px;
  background-color: #fff;
  white-space: nowrap;
  padding-left: 15px;

  img {
    width: 45px;
    height: 40px;
    margin-right: 10px;
  }
}
</style>